<template>
	<div class="heightMax publicbox" v-loading='tableLoading'>
		<div class="header">
			<div class="listName">
				<i></i><span class="font14">用户列表</span>
			</div>
			<div>
				<el-button type="primary" size="mini" @click="enture('form')" v-loading='btnLoading' v-if="!isDisabled">保存</el-button>
				<el-button size="mini" @click='backRouter'>返回</el-button>
			</div>
		</div>
		<vueScroll>
			<div class="content">
				<el-form ref="form" :model="form" :rules="rules" label-width="130px">
					<el-row :gutter="20">
						<el-col :span="7" :offset='1'>
							<el-form-item label="用户名:" prop="userName">
								<el-input v-model.trim="form.userName" placeholder="请输入用户名" size="mini" clearable :disabled='isDisabled'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="真实姓名:" prop="trueName">
								<el-input v-model.trim="form.trueName" placeholder="请输入真实姓名" size="mini" clearable :disabled='isDisabled'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="性别" prop="sex">
								<el-select v-model="form.sex" placeholder="请选择性别" size="mini" clearable :disabled='isDisabled'>
									<el-option label="男" :value="1"></el-option>
									<el-option label="女" :value="0"></el-option>
								</el-select>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="7" :offset='1'>
							<el-form-item label="用户类型:" prop="userType">
								<el-select v-model="form.userType" placeholder="请选择用户类型" size="mini" clearable :disabled='nowStatus != 0'
								 @change="userTypeChange">
									<el-option v-for="(item,index) in userTypeArr" :label="item.label" :value="item.value" :key='index'></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="邮箱:">
								<el-input v-model="form.email" placeholder="请输入邮箱" size="mini" clearable :disabled='isDisabled'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7">
							<el-form-item label="角色名称:" prop="roleType">
								<el-select v-model="form.roleType" placeholder="请选择角色名称" size="mini" remote reserve-keyword :loading="roleSearchloading"
								 filterable clearable :disabled='isDisabled' @change="roleValueChange">
									<el-option v-for="(item) in roleTypeArr" :label="item.role_name" :value="item.id" :key='item.id'></el-option>
								</el-select>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="7" :offset='1'>
							<el-form-item label="手机号:" prop="phone">
								<el-input v-model="form.phone" placeholder="请输入手机号" size="mini" clearable :disabled='isDisabled'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" v-if="nowStatus == 0">
							<el-form-item label="登录密码:" prop="pwd">
								<el-input v-model="form.pwd" placeholder="请输入登录密码" size="mini" clearable show-password :disabled='isDisabled'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" v-if="nowStatus == 0">
							<el-form-item label="确认密码:" prop="affirmPwd">
								<el-input v-model="form.affirmPwd" placeholder="请确认密码" size="mini" clearable show-password :disabled='isDisabled'></el-input>
							</el-form-item>
						</el-col>
						<el-col :span="7" v-if="nowStatus == 1">
							<el-form-item label="重置密码:">
								<el-button type="primary" size="mini" class='fl' style='margin-top: 7px;' @click='resetPwd'>重置用户密码</el-button>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="7" :offset='1' v-if="form.userType == 10 || form.userType == 20 ">
							<el-form-item label="关联维保单位" prop="mainCompany">
								<el-select v-model="form.mainCompany" placeholder="请选择维保单位" size="mini" remote :remote-method="mainComRemoteMethod"
								 reserve-keyword :loading="mainComLoading" filterable clearable :disabled='isDisabled' @change="mainChange">
									<el-option v-for="(item) in mainCompanyArr" :label="item.name" :value="item.id" :key='item.id'></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="7" :offset='1' v-if="form.userType == 30">
							<el-form-item label="关联使用单位" prop="userCompany">
								<el-select v-model="form.userCompany" placeholder="请选择使用单位" size="mini" remote :remote-method="userComRemoteMethod"
								 reserve-keyword :loading="mainComLoading" filterable clearable :disabled='isDisabled' @change="userChange">
									<el-option v-for="(item) in userCompanyArr" :label="item.name" :value="item.id" :key='item.id'></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="7" :offset='1' v-if="form.userType == 40">
							<el-form-item label="关联监管单位" prop="jgCompany">
								<el-select v-model="form.jgCompany" placeholder="请选择监管单位" size="mini" remote :remote-method="jgComRemoteMethod"
								 reserve-keyword :loading="mainComLoading" filterable clearable :disabled='isDisabled'>
									<el-option v-for="(item) in jgCompanyArr" :label="item.name" :value="item.id" :key='item.id'></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="14" :offset='form.userType == "" ? 1 : 0' v-show="optional">
							<el-form-item label="已自选电梯:">
								<el-select size="mini" v-model="choseLiftList" clearable :disabled='isDisabled' multiple placeholder="请点击选授权电梯">
									<el-option v-for="(item,index) in choseLiftArr" :value="item" :label="item" :key='index'>
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="7" :offset='1'>
							<el-form-item label="权限类型:" prop="jurisdiction">
								<el-select v-model="form.jurisdiction" placeholder="请选择权限类型" size="mini" clearable :disabled="isDisabled"
								 @change='jurisdictionChange'>
									<el-option v-for="(item,index) in jurisdictionArr" :label="item.label" :value="item.value" :key='index'></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-button type="primary" size="mini" class='fl' style='margin-top: 7px;' v-show="optional" @click='choseLift'
						 :disabled="isDisabled">选择授权电梯</el-button>
					</el-row>
					<el-row :gutter="20">
						<el-col :span="14" :offset='1'>
							<el-form-item label="备注:">
								<el-input type="textarea" resize='none' :autosize="{ minRows: 4, maxRows: 6}" v-model="form.des" placeholder="请输入备注"
								 size="mini" clearable :disabled='isDisabled'></el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<!-- v-if='form.userType == 10' -->
					<MainPerson @getChildValue="getChildValue" @fileList1Change="fileList1Change" @fileList2Change="fileList2Change"
					 @fileList3Change="fileList3Change" @fileList4Change="fileList4Change" :nowStatus='nowStatus' v-if='form.userType == 10'></MainPerson>
				</el-form>
			</div>
		</vueScroll>
	</div>
</template>

<script>
	import {
		loadFn,
		axiosPost,
		axiosGet,
		axiosDelete,
		axiosPut,
		AllLoading,
		axiosChange
	} from "@/common.js";
	import {
		userName,
		trueName,
		sex,
		userType,
		countType,
		selectedData,
		phone,
		jurisdiction,
		roleType,
		userCompany,
		personStatus,
		identity,
		homeAddress,
		pactStartTime,
		pactEndTime,
		mainCompany,
		jgCompany
	} from './rules.js'
	import MainPerson from './mainPerson.vue'
	export default {
		name: 'addRole',
		components: {
			MainPerson
		},
		props: {
			nowStatus: {
				type: Number,
				default () {
					return 0 //0是新增  1是编辑  2是详情
				}
			}
		},
		activated() {
			this.changeUserTypeArr()
			if (this.role == 30) {
				this.$set(this.form, 'userType', 30)
			}
			if (localStorage.choseLiftData) {
				this.$store.state.choseLiftData = JSON.parse(localStorage.choseLiftData).data
				this.choseLiftList = this.$store.state.choseLiftData
			} else {
				if (this.nowStatus) {
					console.log('编辑')
					this.userTypeArr.push({
						label: '维保人员',
						value: 10
					})
					if (localStorage.roleCurrentId) {
						this.roleCurrentId = JSON.parse(localStorage.roleCurrentId).id
					} else {
						this.roleCurrentId = ''
					}
					this.getComplieList()
				} else {
					this.resetFormValue()
				}
			}
		},
		deactivated() {
			localStorage.removeItem('choseLiftData')
		},
		mounted() {

		},
		data() {
			let validatePass = (rule, value, callback) => {
				if (value === '') {
					callback(new Error('请输入密码'));
				} else {
					if (this.form.affirmPwd !== '') {
						this.$refs.form.validateField('affirmPwd');
					}
					callback();
				}
			};
			let validatePass2 = (rule, value, callback) => {
				if (value === '') {
					callback(new Error('请再次输入密码'));
				} else if (value !== this.form.pwd) {
					callback(new Error('两次输入密码不一致!'));
				} else {
					callback();
				}
			};
			let valiPic = (rule, value, callback) => {
				if (this.fileList3.length === 0) {
					callback(new Error('请上传劳动合同附件'));
				} else {
					callback();
				}
			};
			let valiPic1 = (rule, value, callback) => {
				if (this.fileList4.length === 0) {
					callback(new Error('请上传社保附件'));
				} else {
					callback();
				}
			};
			return {
				mainComLoading: false,
				userComLoading: false,
				btnLoading: false,
				tableLoading: false,
				choseLiftList: [],
				choseLiftArr: [],
				mainCompanyArr: [],
				userCompanyArr: [],
				jgCompanyArr: [],
				userTypeArr: [],
				fileList1: [], //劳动照片
				fileList2: [], //社保附件
				fileList3: [], //劳动照片
				fileList4: [], //社保附件
				form: {
					mainCompany: '',
					userCompany: '',
					jgCompany: '',
					userName: '',
					trueName: '',
					sex: '',
					userType: '',
					phone: '',
					email: '',
					roleType: '',
					pwd: '',
					affirmPwd: '',
					des: '',
					jurisdiction: '',
					personStatus: '', //维保人员字段
					identity: '',
					homeAddress: '',
					t1Papers: '',
					t1PapersTime: '',
					t2Papers: '',
					t2PapersTime: '',
					pactStartTime: '',
					pactEndTime: '',
				},
				optional: false, //选择授权电梯按钮是否显示
				rules: {
					pwd: [{
						validator: validatePass,
						trigger: 'blur',
						required: true
					}, {
						min: 4,
						max: 20,
						message: '密码长度在 4 到 20 个字符',
						trigger: 'blur'
					}],
					affirmPwd: [{
						validator: validatePass2,
						trigger: 'blur',
						required: true
					}],
					userName,
					trueName,
					sex,
					userType,
					selectedData,
					phone,
					jurisdiction,
					roleType,
					userCompany,
					jgCompany,
					personStatus,
					mainCompany,
					identity: [{
						required: true,
						trigger: 'blur',
						validator: identity
					}],
					pactAffix: [{
						required: true,
						trigger: 'blur',
						validator: valiPic
					}],
					pactAffix1: [{
						required: true,
						trigger: 'blur',
						validator: valiPic1
					}],
					homeAddress,
					pactStartTime,
					pactEndTime,
				},
				jurisdictionArr: [{
						label: '角色',
						value: 10,
					},
					{
						label: '自选',
						value: 20,
					},
				],
				roleTypeArr: [],
				//tree
				defaultProps: {
					children: 'childrenList',
					label: 'menuName'
				},
				nodeKey: 'menuId',
				defaultCheckedKeys: [],
				roleSearchloading: false,
				roleCurrentId: ''
			}
		},
		computed: {
			useCompanyDis() {
				if (this.role == 30) {
					return false
				} else {
					return true
				}
			},
			isOrg() {
				if (this.form.userType !== '') {
					return false
				} else {
					return true
				}
			},
			showMainCompany() {
				if (this.form.userType == 20 || this.form.userType === 0) {
					return true
				} else {
					return false
				}
			},
			offsetNow() {
				if (this.form.userType == 10) {
					return 1
				} else {
					return 0
				}
			},
			role() {
				if (localStorage.role) {
					return JSON.parse(localStorage.role).id
				} else {
					return ''
				}
			},
			isDisabled() {
				if (this.nowStatus == 2) {
					return true
				} else {
					return false
				}
			}
		},
		methods: {
			//清空
			resetFormValue() {
				this.optional = false
				this.choseLiftList = []
				this.fileList1 = [] //劳动照片
				this.fileList2 = [] //社保附件
				this.fileList3 = [] //劳动照片
				this.fileList4 = [] //社保附件
				this.userCompanyArr = []
				this.mainCompanyArr = []
				this.jgCompanyArr = []
				this.form.pwd = ''
				this.form.userCompany = ''
				this.form.roleType = ''
				this.roleTypeArr = []
				this.$refs['form'].resetFields();
			},
			//用户类型改变
			userTypeChange(res) {
				if (res !== '') {
					let type = ''
					if (res == 10 || res == 20) {
						type = 100
					} else if (res == 30) {
						type = 300
					} else if (res == 40) {
						type = 400
					}
					this.getUserNameList()
					if (res != 0) {
						this.getMainComp('', type)
					}
				}
			},
			//维保单位值变化
			mainChange(res) {
				if (!res) {
					this.getMainComp('', 100)
				}
			},
			//使用单位值变化
			userChange(res) {
				if (!res) {
					this.getMainComp('', 300)
				}
			},
			//监管单位值变化
			jgchange1(res) {
				if (!res) {
					this.getMainComp('', 400)
				}
			},
			//获取维保单位
			getMainComp(keyWords = '', type = 100) {
				let params = {
					key_words: keyWords,
					company_type: type
				}
				axiosGet('/user/user/company/', params, (res) => {
					if (res.code == 0) {
						if (type == 100) {
							this.mainCompanyArr = res.detail.results
						} else if (type == 300) {
							this.userCompanyArr = res.detail.results
						} else if (type == 400) {
							this.jgCompanyArr = res.detail.results
						}
					} else {
						this.$message.error(res.detail.result)
					}
				})
			},
			userComRemoteMethod(keyWords) {
				this.getMainComp(keyWords, 300)
			},
			mainComRemoteMethod(keyWords) {
				this.getMainComp(keyWords, 100)
			},
			jgComRemoteMethod(keyWords) {
				this.getMainComp(keyWords, 400)
			},
			//组件form变化
			getChildValue(res) {
				console.log(res)
				Object.assign(this.form, this.form, res.value)
			},
			//t1附件
			fileList1Change(res) {
				this.fileList1 = res.value
			},
			//t2附件
			fileList2Change(res) {
				console.log(res)
				this.fileList2 = res.value
			},
			//劳动合同
			fileList3Change(res) {
				this.fileList3 = res.value
			},
			//社保
			fileList4Change(res) {
				this.fileList4 = res.value
			},
			//上传照片接口
			uploadImage(imgList, i) {
				if (imgList.length > 0) {
					const formData = new FormData();
					formData.append("upfile", imgList[i].raw)
					return this.$axios({
						url: "/utils/upload/",
						method: "post",
						data: formData
					})
				}
			},
			//用户类型变化
			changeUserTypeArr() {
				if (this.role == 0) {
					this.userTypeArr = [{
							label: '平台管理员',
							value: 0,
						},
						{
							label: '维保单位管理员',
							value: 20,
						},
						{
							label: '使用单位用户',
							value: 30,
						},
						{
							label: '监管单位用户',
							value: 40,
						}
					]
				} else if (this.role == 20) {
					this.userTypeArr = [{
							label: '维保人员',
							value: 10,
						},
						{
							label: '维保单位用户',
							value: 20,
						},
						{
							label: '使用单位用户',
							value: 30,
						}
					]
				} else if (this.role == 30) {
					this.userTypeArr = [{
						label: '使用单位用户',
						value: 30,
					}]
				} else if (this.role == 40) {
					this.userTypeArr = [{
						label: '监管单位用户',
						value: 40,
					}]
				}

			},
			//获取编辑数据
			getComplieList() {
				this.tableLoading = true
				let url = '/user/user/' + this.roleCurrentId
				axiosGet(url, {}, (res) => {
					if (res.code == 0) {
						this.tableLoading = false
						this.form.userName = res.detail.username
						this.form.trueName = res.detail.real_name
						this.form.sex = res.detail.gender
						this.form.userType = res.detail.role
						this.form.phone = res.detail.phone
						this.form.des = res.detail.desc
						this.form.email = res.detail.email
						this.form.jurisdiction = res.detail.permission_type
						let eleArr = res.detail.elevators.map((item) => item)
						this.choseLiftArr = eleArr
						this.choseLiftList = eleArr
						if (this.form.jurisdiction == 20) {
							this.optional = true
						} else {
							this.optional = false
						}
						if (this.form.userType == 10 || this.form.userType == 20) {
							this.form.mainCompany = res.detail.company_id
							this.mainCompanyArr = [{
								id: res.detail.company_id,
								name: res.detail.company_name
							}]
						}
						if (this.form.userType == 30) {
							this.form.userCompany = res.detail.company_id
							this.userCompanyArr = [{
								id: res.detail.company_id,
								name: res.detail.company_name
							}]
						}
						if (this.form.userType == 40) {
							this.form.jgCompany = res.detail.company_id
							this.jgCompanyArr = [{
								id: res.detail.company_id,
								name: res.detail.company_name
							}]
						}
						if (res.detail.admin_role && res.detail.admin_role_name) {
							this.form.roleType = res.detail.admin_role
							this.roleTypeArr = [{
								role_name: res.detail.admin_role_name,
								id: res.detail.admin_role
							}]
						} else {
							this.getUserNameList()
						}
					} else {
						this.$message.error(res.detail.result)
					}
				})
			},
			//重置密码
			resetPwd() {
				this.$confirm('此操作将重置密码为 -> 12345 , 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$message({
						type: 'success',
						message: '重置密码成功'
					})
					this.form.pwd = '12345'
				}).catch(() => {

				});
			},
			//获取角色名称列表
			getUserNameList(keyWords = '') {
				this.roleSearchloading = true
				let params = {
					page: 1,
					page_size_count: 30,
					key_words: keyWords,
					role_type: this.form.userType
				}
				axiosGet('/user/role/', params, (res) => {
					this.roleSearchloading = false
					if (res.code == 0) {
						this.roleTypeArr = res.detail.results
					} else {
						this.$message.error(res.detail.result)
					}
				})
			},
			//角色下拉清空重新获取角色信息
			roleValueChange(value) {
				if (!value) {
					this.getUserNameList()
				}
			},
			//角色下拉开启远程搜索
			roleRmote(keyWords) {
				this.getUserNameList(keyWords)
			},
			//选择授权电梯
			choseLift() {
				localStorage.roleOperation = JSON.stringify({
					id: ''
				})
				if (this.nowStatus) { //编辑
					localStorage.isUser = JSON.stringify({
						isTrue: 2
					})
				} else {
					localStorage.isUser = JSON.stringify({
						isTrue: 1
					})
				}
				let obj = {
					newLabel: '电梯授权',
					index: '/MainView/SystemManagement/ChoseAuthorizedElevator'
				}
				this.$store.commit('ADDTAB', obj)
				this.$router.push({
					name: 'ChoseAuthorizedElevator'
				})
			},
			//权限类型改变
			jurisdictionChange(value) {
				if (value == 20) {
					this.optional = true
				} else {
					this.optional = false
				}
			},
			//返回父级路由
			backRouter() {
				let obj = {
					name: '用户管理',
					router: '/MainView/SystemManagement/UserCountManage'
				}
				this.resetFormValue()
				this.$store.state.choseLiftData = []
				this.$store.commit('GOTAGROUTER', obj)
			},
			//保存
			enture(formName) {
				this.$refs[formName].validate(async (valid) => {
					if (valid) {
						this.btnLoading = true
						if (this.form.jurisdiction == 10) {
							this.choseLiftList = []
						}
						let company = ''
						if (this.form.mainCompany) {
							company = this.form.mainCompany
						}
						if (this.form.userCompany) {
							company = this.form.userCompany
						}
						if (this.form.jgCompany) {
							company = this.form.jgCompany
						}
						let data = {
							username: this.form.userName,
							real_name: this.form.trueName,
							gender: this.form.sex,
							email: this.form.email,
							phone: this.form.phone,
							pwd: this.form.pwd,
							role: this.form.userType,
							admin_role: this.form.roleType,
							desc: this.form.des,
							permission_type: this.form.jurisdiction,
							register_codes: this.choseLiftList,
							company: company,
							lift: localStorage.eleLib ? (JSON.parse(localStorage.eleLib).id).toString() : '0'
						}

						if (this.form.userType == 10) { //维保人员
							if (this.fileList1.length == 0 && this.fileList2.length == 0) {
								this.$message.info('T1证附件/T2证附件请至少上传一份')
								this.btnLoading = false
								return false
							}
							if (this.fileList1.length != 0 && !this.form.t1Papers) {
								this.$message.info('T1证号码不能为空')
								this.btnLoading = false
								return false
							}
							if (this.fileList1.length != 0 && !this.form.t1PapersTime) {
								this.$message.info('T1证有效期不能为空')
								this.btnLoading = false
								return false
							}

							if (this.fileList2.length != 0 && !this.form.t2Papers) {
								this.$message.info('T2证号码不能为空')
								this.btnLoading = false
								return false
							}
							if (this.fileList2.length != 0 && !this.form.t2PapersTime) {
								this.$message.info('T2证有效期不能为空')
								this.btnLoading = false
								return false
							}
							//上传照片
							let upImg1 = ''
							let upImg2 = ''
							let upImg3 = ''
							let upImg4 = ''
							// 							if (this.fileList1.length != 0) {
							// 								if (this.fileList1[0].raw) {
							// 									const uploadRes = await this.uploadImage(this.fileList1, 0)
							// 									upImg1 = uploadRes.code === 0 ? uploadRes.detail : ''
							// 								} else {
							// 									upImg1 = this.fileList1[0].url;
							// 								}
							// 							}
							if (this.fileList1.length != 0) {
								upImg1 = []
								let permises = []
								for (let i = 0; i < this.fileList1.length; i++) {
									if (this.fileList1[i].raw) {
										await permises.push(this.uploadImage(this.fileList1, i));
										permises[i].code === 0 && upImg1.push(permises[i].detail)
									} else {
										upImg1.push(this.fileList1[i].url);
									}
								}
								const res = await Promise.all(permises);
								for (let i = 0; i < res.length; i++) {
									res[i].code === 0 && upImg1.push(res[i].detail)
								}
							}
							// 							if (this.fileList2.length != 0) {
							// 								if (this.fileList2[0].raw) {
							// 									const uploadRes = await this.uploadImage(this.fileList2, 0)
							// 									upImg2 = uploadRes.code === 0 ? uploadRes.detail : ''
							// 								} else {
							// 									upImg2 = this.fileList2[0].url
							// 								}
							// 							}
							if (this.fileList2.length != 0) {
								upImg2 = []
								let permises = []
								for (let i = 0; i < this.fileList2.length; i++) {
									if (this.fileList2[i].raw) {
										await permises.push(this.uploadImage(this.fileList2, i));
										permises[i].code === 0 && upImg2.push(permises[i].detail)
									} else {
										upImg2.push(this.fileList2[i].url);
									}
								}
								const res = await Promise.all(permises);
								for (let i = 0; i < res.length; i++) {
									res[i].code === 0 && upImg2.push(res[i].detail)
								}
							}
							if (this.fileList4.length != 0) {
								if (this.fileList4[0].raw) {
									const uploadRes = await this.uploadImage(this.fileList4, 0)
									upImg4 = uploadRes.code === 0 ? uploadRes.detail : ''
								} else {
									upImg4 = this.fileList4[0].url
								}
							}
							//传多张
							if (this.fileList3.length != 0) {
								upImg3 = []
								let permises = []
								for (let i = 0; i < this.fileList3.length; i++) {
									if (this.fileList3[i].raw) {
										await permises.push(this.uploadImage(this.fileList3, i));
										permises[i].code === 0 && upImg3.push(permises[i].detail)
									} else {
										upImg3.push(this.fileList3[i].url);
									}
								}
								const res = await Promise.all(permises);
								for (let i = 0; i < res.length; i++) {
									res[i].code === 0 && upImg3.push(res[i].detail)
								}
							}

							data.t1_card_file = typeof upImg1 == 'string'? '' :  upImg1.join(',')
							data.t2_card_file = typeof upImg2 == 'string'? '' :  upImg2.join(',')
							data.contract_file = upImg3
							data.social_security = upImg4
							data.home_addr = this.form.homeAddress
							data.contract_start_time = this.form.pactStartTime
							data.contract_end_time = this.form.pactEndTime
							data.status = this.form.personStatus //人员状态
							data.card_id = this.form.identity //身份证号
							data.t1_card_no = this.form.t1Papers //T1证号
							data.t1_end_time = this.form.t1PapersTime, //T1证有效期
							data.t2_card_no = this.form.t2Papers //T2证号
							data.t2_end_time = this.form.t2PapersTime //T2证有效期
						}
						localStorage.removeItem('roleCountMess')
						localStorage.removeItem('choseLiftData')
						let url = ''
						let method = ''
						if (!this.nowStatus) {
							url = '/user/user/'
							method = 'post'
						} else {
							url = '/user/user/' + this.roleCurrentId + '/'
							method = 'put'
						}
						axiosChange(url, method, data, (res) => {
							this.btnLoading = false
							if (res.code == 0) {
								localStorage.removeItem('eleLib')
								localStorage.RoleManagementFlush = JSON.stringify({
									flush: 1
								})
								this.$message({
									type: 'success',
									message: '操作成功'
								})
								this.backRouter()
							} else if (res.code == 41017) {
								this.$message.error('手机号不正确，请重新输入')
							} else if (res.code == 41019) {
								this.$message.error('email不正确，请重新输入')
							} else {
								this.$message.error(res.detail.result)
							}
						})
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
		},
	}
</script>

<style scoped lang='less'>
	.header {
		display: flex;
		justify-content: space-between;
	}

	.content {
		height: 90%;
		width: 100%;
		margin-top: 5px;
	}

	.listName {
		display: flex;
		justify-content: flex-start;
		text-align: left;
		height: 25px;
		align-items: center;

		i {
			width: 3px;
			height: 60%;
			background: #2d8cf0;
			margin: 10px 5px;
			margin-left: 0;
		}

	}

	.el-row {
		margin-right: 0 !important;
		margin-left: 0 !important;
	}
</style>
